"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""
from typing import List, Tuple


class TenXClass:
    def __init__(self):
        self.name = "顾家忻"
        self.id = "3124002007"

    @staticmethod
    def question1(n: int) -> list[str]:
        print(n)  # 打印，防止IDE警告
        def RESULT(n):
            result = []
            for num in range(1, n + 1):
                if num == 0:
                    result.append("0")
                else:
                    number = ""
                    while num:
                        num, rem = divmod(num, 4)
                        number = str(rem) + number
                    result.append(number)
            return result
        return RESULT(n)

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        TOTAL = 100
        RESULT02 = []
        for x in range(20):
            for y in range(34):
                z = 100 - x - y
                if z%3 == 0 and x*5+y*3+z//3==100:
                    RESULT_01 = (x,y,z)
                    RESULT02.append(RESULT_01)
        return RESULT02

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        EQUIPMENT = []
        PROP = []
        MATERIAL = []
        for m in range(len(items)):
            if items[m] in equipment:
                EQUIPMENT.append(items[m])
            elif items[m] in prop:
                PROP.append(items[m])
            else:
                MATERIAL.append(items[m])
        RESULT03 = dict([("equipment",EQUIPMENT),("prop",PROP),("material",MATERIAL)])
        return RESULT03

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        print(item_values, items)  # 打印，防止IDE警告
        VALUES = []
        ITEMS = []
        for m in range(len(items)):
            VALUES.append(item_values.get(items[m]))
        VALUES.sort(reverse=True)
        Result_values = VALUES[0:3:1]
        x,y,z = Result_values
        Result_all = x + y + z
        Result_items = []
        for n in range(len(items)):
            a = item_values.get(items[n])
            j,k,l = 0,0,0
            if a == x and j == 0:
                Result_items.append(items[n])
                j += 1
            if a == y and k == 0:
                Result_items.append(items[n])
                k += 1
            if a == z and l == 0:
                Result_items.append(items[n])
                l += 1
        Result = (Result_items,Result_all)
        return Result
    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        print(matrix)  # 打印，防止IDE警告
        def find_doors(matrix):
            doors = []
            for i in range(len(matrix)):
                for j in range(len(matrix[i])):
                    if matrix[i][j] == 0:
                        doors.append((i + 1, j + 1))
            return doors
        return find_doors(matrix)
